# Compatibility
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)

# Project name
PROJECT (sp)

# Project version
SET (${PROJECT_NAME}_MAJOR_VERSION 0)
SET (${PROJECT_NAME}_MINOR_VERSION 1)
SET (${PROJECT_NAME}_PATCH_LEVEL 0)

SET (SPAWNER_PATH "${CMAKE_BINARY_DIR}/sp")
SET (BUILD_DIR "${CMAKE_BINARY_DIR}")
SET (ROOT_DIR "${PROJECT_SOURCE_DIR}")
SET (PROTOTYPE_TESTER "${ROOT_DIR}/bin/sp.exe")

INCLUDE(FindPythonInterp)

ADD_SUBDIRECTORY("${PROJECT_SOURCE_DIR}/libspawner" libspawner)
ADD_SUBDIRECTORY("${PROJECT_SOURCE_DIR}/test" tests)

ENABLE_TESTING()
INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/inc")
INCLUDE_DIRECTORIES ("${PROJECT_SOURCE_DIR}/libspawner")

#OPTION(MYPROJECT_DEBUG "Build the project using debugging code" ON)

SET (CMAKE_BUILD_TYPE Debug)

#IF(MYPROJECT_DEBUG)
#  SET_SOURCE_FILE_PROPERTIES(
#    libSource.c main.c
#    COMPILE_FLAGS -DDEBUG)
#ENDIF(MYPROJECT_DEBUG)

# fix relative path
FILE (GLOB SOURCES ./src/*.cpp)
FILE (GLOB HEADERS ./inc/*.h)

FILE (GLOB LIB_WIN32_SOURCES "./src/win32/*.cpp")
FILE (GLOB LIB_NIX_SOURCES ./src/nix/*.cpp)

#SET (SOURCES ${SOURCES} "./src/main.cpp")


IF (UNIX)
	SET (SOURCES ${SOURCES} ${NIX_SOURCES})
ELSE (UNIX)
	IF (WIN32)
		SET (SOURCES ${SOURCES} ${WIN32_SOURCES})
	ENDIF (WIN32)
ENDIF (UNIX)

#SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS:STRING 

SET (PROJECT_EXECUTABLE ${PROJECT_NAME})
SET(CMAKE_EXE_LINKER_FLAGS "-static")


ADD_EXECUTABLE (${PROJECT_EXECUTABLE} ${SOURCES} ${HEADERS})
#set_target_properties(${PROJECT_EXECUTABLE}                               PROPERTIES COMPILE_FLAGS "-static")

TARGET_LINK_LIBRARIES(${PROJECT_EXECUTABLE} libspawner)
TARGET_LINK_LIBRARIES(${PROJECT_EXECUTABLE} ntdll)